package com.xggstudio.crm.api;

import android.content.Context;
import com.xggstudio.crm.base.App;
import com.xggstudio.crm.tools.NetUtils;

import rx.Subscriber;

/**
 * Created by PC_L on 2018/1/9.
 */

public abstract class NetCheckerSubscriber<T> extends Subscriber<T> {

    public NetCheckerSubscriber(Context context) {
        //this.context = context;
    }
    public NetCheckerSubscriber() {
    }

    @Override
    public void onStart() {
        super.onStart();

        if(!NetUtils.isNetworkConnected(App.getInstance())) {
            if (!isUnsubscribed()) {
                unsubscribe();
            }
            onNoNetError();

        }
    }

    protected abstract void onNoNetError();
}
